/**
 * [countDownBySecond 倒计时]
 * @param  {[Int]} restSeconds   [剩余秒数，必填]
 * @param  {[Int]} timeInterval   [时间间隔，非必填，默认1000ms]
 * @param  {[Function]} func   [每倒计时一次，就需要执行一次的回调函数名，非必填]
 * @param  {[Function]} endFun [倒计时结束需要执行的函数名，非必填]
 * @return {[null]}        [无返回值]
 */
export function countDownBySecond(restSeconds, timeInterval, func, endCallback) {
    let timer = null;
    let total = restSeconds;
    timeInterval = timeInterval ? timeInterval : 1000;
    timer = setInterval(function () {
        --total;
        if (total <= 0) {
            clearInterval(timer);
            endCallback && endCallback();
        }
        func && func(total);
    }, timeInterval);
}
